﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcVietAir.Models;

namespace MvcVietAir.Controllers
{
    public class ContactController : Controller
    {
        private RepositoryContacts repo = new RepositoryContacts();
        Contact ct = null;
        //
        // GET: /Contact/Create/

        public ActionResult Create(Contact contact)
        {
            return View(contact);
        }


        //
        // GET: /Contact/Create/5

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Create(Contact contact, FormCollection collection)
        {
            if (ModelState.IsValid)
            {
                int result = repo.Create(contact);
                if (result > 0)
                {
                    ct = contact;
                    return RedirectToAction("Thanks");
                }
            }
            return View(contact);
        }

        //
        // GET: /Contact/Thanks
        public ActionResult Thanks()
        {
            ViewData["ContactInfo"] = ct;
            return View();
        }
    }
}
